$(function(){
    $("#userForm").ajaxForm({
        beforeSubmit: function (formData, jqForm, options) {
            var form = jqForm[0];
            var username = form.username.value;
            var userpass = form.userpass.value;
            if(!checkNotNull(username)||!checkNotNull(userpass)){
                $("#warnblank").html("请填写用户名和密码!");
                return false;
            }
            $("#warnblank").html("登录中...");
            return true;
        },
        success: function(jsonObj) {
            var code = jsonObj.code;
            if(code=="0001"){
                $("#warnblank").html("请填写用户名和密码!");
                return false;
            }else if(code=="0002"){
                $("#warnblank").html("用户名与密码不匹配，请重新输入!");
                return false;
            }else if(code=="0000"){
                $("#warnblank").html("登录成功,正在跳转...");
                window.location.href="admin/index";
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            $("#warnblank").html("登录异常["+textStatus+"："+errorThrown+"]，请及时反馈客服!");
        },
        type: 'post',
        dataType: 'json',
        resetForm: false,
        timeout: 30000
    });
});
